package com.fengye.ms.demo.controller;

import com.fengye.ms.demo.model.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;

/**
 *
 * @author sky
 * @version 1.0
 * @since 2021/3/30 09:06
 */
@RestController
@RequestMapping("/users")
public class UserController {

    @GetMapping()
    public List<User> list(){
        List<User> list = new ArrayList<User>();
        list.add(new User());
        list.add(new User());
        list.add(new User());
        list.add(new User());
        Random random = new Random();
        return list.stream().peek(user -> {
            user.setId(random.nextLong());
        }).collect(Collectors.toList());
    }
}
